<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>父组件和子组件</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
      <cpn2></cpn2>
  </div>

  <script>
    //  创建父组件
    const cpnC1 = Vue.extend({
      template: `
        <div>
          <h2>我是标题1</h2>
          <P>我是内容，哈哈哈哈</P> 
        </div>
      `
    });
    // 创建子组件
    const cpnC2 = Vue.extend({
      template: `
        <div>
          <h2>我是标题2</h2>
          <P>我是内容，嘻嘻嘻嘻</P> 
          <cpn1></cpn1>
        </div>
      `,
      components: {
        cpn1: cpnC1
      }
    })
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      components: {
        cpn2: cpnC2
      }
    });
  </script>
</body>

</html>